package com.sjgtw.cloud.web.rainfallMonitoring.controller;

import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;
import com.sjgtw.cloud.common.core.web.controller.BaseController;
import com.sjgtw.cloud.common.core.web.domain.AjaxResult;
import com.sjgtw.cloud.common.core.web.page.TableDataInfo;
import com.sjgtw.cloud.web.rainfallMonitoring.domain.RainfallMonitoring;
import com.sjgtw.cloud.web.rainfallMonitoring.service.IRainfallMonitoringService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 雨量监测记录Controller
 * 
 * @author ruoyi
 * @date 2024-03-17
 */
@RestController
@Api(tags = "3.2、雨量记录")
@RequestMapping("/rainfallMonitoring")
public class RainfallMonitoringController extends BaseController
{
    @Autowired
    private IRainfallMonitoringService rainfallMonitoringService;

    /**
     * 查询雨量监测记录列表
     */

    @GetMapping("/list")
    @ApiOperation("列表")
    public TableDataInfo list(RainfallMonitoring rainfallMonitoring)
    {
        startPage();
        List<Map<String,Object>> list = rainfallMonitoringService.selectRainfallMonitoringList(rainfallMonitoring);
        return getDataTable(list);
    }

    /**
     * 雨量报警接口测试
     * @param jsonObject
     * @return
     */
    @PostMapping("/alarm")
    @ApiOperation("检测")
    public AjaxResult alarm(@RequestBody JSONObject jsonObject)
    {
        return rainfallMonitoringService.alarm(jsonObject);

    }



    /**
     * 获取雨量监测记录详细信息
     */

/*
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(rainfallMonitoringService.selectRainfallMonitoringById(id));
    }
*/

    /**
     * 新增雨量监测记录
     */

    @PostMapping("/add")
    public AjaxResult add(@RequestBody RainfallMonitoring rainfallMonitoring)
    {
        return toAjax(rainfallMonitoringService.insertRainfallMonitoring(rainfallMonitoring));
    }

    /**
     * 修改雨量监测记录
     */

    @PutMapping
    public AjaxResult edit(@RequestBody RainfallMonitoring rainfallMonitoring)
    {
        return toAjax(rainfallMonitoringService.updateRainfallMonitoring(rainfallMonitoring));
    }

    /**
     * 删除雨量监测记录
     */

	@DeleteMapping("/delete/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(rainfallMonitoringService.deleteRainfallMonitoringById(id));
    }
}
